package io.yunho.yunho.interview.two.java8.stream;

import java.util.stream.IntStream;

/**
 * @author: Jason
 * @date: 2021/5/5 9:52
 * @description:
 */
public class SteamTest {
    public static void main(String[] args) {
        //sum demo
        int[] nums = {1,3,4};
        int sum=0;
        for (int i : nums
             ) {
            sum+=i;
        }
        System.out.println(sum);

        int sums = IntStream.of(nums).sum();
        System.out.println(sums);

        //peek demo
        IntStream intStream = IntStream.range(50, 60);
        System.out.println("流中的元素 = ");
        long res = intStream.peek(System.out::println).count();
        System.out.println("元素计数 = " + res);

    }
}
